package com.example;

import com.example.config.AppConfig;
import com.example.service.OrderService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class AopTest {
    public static void main(String[] args) {
        // 初始化Spring容器
        ApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);
        OrderService orderService = context.getBean(OrderService.class);

        System.out.println("=====测试add方法=====");
        try {
            orderService.add("笔记本电脑", 1);
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }

        System.out.println("\n=====测试delete方法=====");
        try {
            orderService.delete("手机");
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }

        System.out.println("\n=====测试find方法=====");
        orderService.find("平板电脑");
    }
}
